package com.tedu.bank_ems1.controller;

import com.tedu.bank_ems1.service.impl.EmpServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Author：毕龙
 * Date: 2024/6/26 14:38
 */
@WebServlet(value = "/emp/delete")
public class DeleteEmpServlet extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println(req.getParameter("id"));
        String id = req.getParameter("id");
        Integer ida = Integer.valueOf(id);
        EmpServiceImpl service = new EmpServiceImpl();
        int i = service.deleteEmp(ida);
        if(i == 1){
            resp.sendRedirect(req.getContextPath() + "/emp/list");
        }else {
            resp.sendRedirect(req.getContextPath() + "/ems/emp/emplist.jsp");
        }

    }
}
